clear all
set mem 9999999
set more off


cd "$dir\Final_Data"

use Final_sample.dta, clear


global treat islam_school christ_school stmusl  stcath ///
 christianchrist3 christianislam3  ///
 islamicchrist3 islamicislam3


 
 cd "$dir\Tables"	


* Less than 66.81% (bottom 25th percentile) from one religion is diverse 
* Diverse 
reghdfe GPA_y1 $treat satmat satverb sex* legacy advsex*   if  firstyear>=2002 & satmat!=. & satverb!=. & qualitychris!=. & qualitymusl!=. & non_div==0 , absorb(i.firstyear##i.Dept1 fake_advisor_id) vce(cluster advisorIDyear)
eststo zab
** PEERS EFFECTS for STUDEnTS FROM SECULAR Schools*** (Secular match)
lincomest stcath //All Secular schools peers relative to all Christian schools peers
eststo row11
estimates restore zab
lincomest stmusl  //All Secular schools peers relative to all Islamic schools peers
eststo  row21
estimates restore zab
** PEERS EFFECTS for STUDEnTS FROM CHRISTIAN Schools*** (Christian match)
lincomest -stcath-christianchrist3  //All Christian schools peers relative to all Secular schools peers
eststo row31
estimates restore zab
lincomest  -stcath-christianchrist3+stmusl+christianislam3 //All Christian schools peers relative to all Islamic schools peers
eststo row41
estimates restore zab
** PEERS EFFECTS for STUDEnTS FROM ISLAMIC Schools*** (Islam match)
lincomest  -stmusl-islamicislam3 //All Islamic schools peers relative to all Secular schools peers7
eststo row51
estimates restore zab
lincomest  -stmusl-islamicislam3+stcath+islamicchrist3 //All Muslim school peers relative to all Christian schools peers
eststo row61
estimates restore zab


* More than 66.81% from one religion is non diverse 
*non diverse
reghdfe GPA_y1 $treat satmat satverb sex* legacy advsex*   if  firstyear>=2002 & satmat!=. & satverb!=. & qualitychris!=. & qualitymusl!=. &  non_div==1 , absorb(i.firstyear##i.Dept1 fake_advisor_id) vce(cluster advisorIDyear)
eststo zab2
lincomest stcath //All Secular schools peers relative to all Christian schools peers
eststo row12
estimates restore zab2
lincomest stmusl  //All Secular schools peers relative to all Islamic schools peers
eststo  row22
estimates restore zab2
** PEERS EFFECTS for STUDEnTS FROM CHRISTIAN Schools*** (Christian match)
lincomest -stcath-christianchrist3  //All Christian schools peers relative to all Secular schools peers
eststo row32
estimates restore zab2
lincomest  -stcath-christianchrist3+stmusl+christianislam3 //All Christian schools peers relative to all Islamic schools peers
eststo row42
estimates restore zab2
** PEERS EFFECTS for STUDEnTS FROM ISLAMIC Schools*** (Islam match)
lincomest  -stmusl-islamicislam3 //All Islamic schools peers relative to all Secular schools peers7
eststo row52
estimates restore zab2
lincomest  -stmusl-islamicislam3+stcath+islamicchrist3 //All Muslim school peers relative to all Christian schools peers
eststo row62
estimates restore zab2





clear 


cd "$dir\Raw_Data"

use base_with_religion.dta
rename _merge merge1
merge m:1 school1 using "school_indexf12.dta"

global treat islam_school christ_school stmusl  stcath ///
 christianchrist3 christianislam3  ///
 islamicchrist3 islamicislam3
 
 encode Dept, gen(Dept2)
 encode Rank, gen(Rank2)
 
 
 **need to merge with old definition of treatment before running regressions*
 drop  islam_school christ_school stmusl  stcath christianchrist3 christianislam3   islamicchrist3 islamicislam3
drop _merge

cd "$dir\Final_Data"
merge m:1 ID using Final_Sample.dta, keepusing(islam_school christ_school stmusl  stcath christianchrist3 christianislam3   islamicchrist3 islamicislam3)


******TABLE 10***********************
cd "$dir\Tables"								
					

 *More than 66.8% from one religion is non diverse (25th percentile is of variable majority from one religion is 0.668)
* Diverse 
reghdfe no_teach $treat satmat satverb sex* legacy advsex*   if year>=2012 & year<=2017 & FR_nonFR_status =="never enrolled as FR" & satmat!=. & satverb!=. & MAJR_CODE!="MJRL"  & bla>10 & bla<=30& non_div==0,   absorb(i.year##i.Dept2 fake_advisor_id) vce(  cluster advisorIDyear)
eststo zab3
** PEERS EFFECTS for STUDEnTS FROM SECULAR Schools*** (Secular match)
lincomest stcath //All Secular schools peers relative to all Christian schools peers
eststo row13		
estimates restore zab3
lincomest stmusl  //All Secular schools peers relative to all Islamic schools peers
eststo row23		
estimates restore zab3
	
reghdfe christ_teach $treat satmat satverb sex* legacy advsex*   if year>=2012 & year<=2017 & FR_nonFR_status =="never enrolled as FR" & satmat!=. & satverb!=. & MAJR_CODE!="MJRL"  & bla>10 & bla<=30  & non_div==0,   absorb(i.year##i.Dept2 fake_advisor_id) vce(  cluster advisorIDyear) 
eststo zab2
** PEERS EFFECTS for STUDEnTS FROM CHRISTIAN Schools*** (Christian match)
lincomest -stcath-christianchrist3  //All Christian schools peers relative to all Secular schools peers
eststo row33	
estimates restore zab2
lincomest -stcath-christianchrist3+stmusl+christianislam3 //All Christian schools peers relative to all Islamic schools peers
eststo row43		
estimates restore zab2
	

reghdfe musl_teach $treat satmat satverb sex* legacy advsex*   if year>=2012 & year<=2017 & FR_nonFR_status =="never enrolled as FR" & satmat!=. & satverb!=. & MAJR_CODE!="MJRL"  & bla>10 & bla<=30 & non_div==0 ,   absorb(i.year##i.Dept2 fake_advisor_id) vce(  cluster advisorIDyear) 
eststo zab
** PEERS EFFECTS for STUDEnTS FROM ISLAMIC Schools*** (Islam match)
lincomest  -stmusl-islamicislam3 //All Islamic schools peers relative to all Secular schools peers7
eststo row53
estimates restore zab
lincomest  -stmusl-islamicislam3+stcath+islamicchrist3 //All Muslim school peers relative to all Christian schools peers
eststo row63
estimates restore zab




* Non diverse 
reghdfe no_teach $treat satmat satverb sex* legacy advsex*   if year>=2012 & year<=2017 & FR_nonFR_status =="never enrolled as FR" & satmat!=. & satverb!=. & MAJR_CODE!="MJRL"  & bla>10 & bla<=30  & non_div==1,   absorb(i.year##i.Dept2 fake_advisor_id) vce(  cluster advisorIDyear) 
eststo zab3
** PEERS EFFECTS for STUDEnTS FROM SECULAR Schools*** (Secular match)
lincomest stcath //All Secular schools peers relative to all Christian schools peers
eststo row14		
estimates restore zab3
lincomest stmusl  //All Secular schools peers relative to all Islamic schools peers
eststo row24	
estimates restore zab3


reghdfe christ_teach $treat satmat satverb sex* legacy advsex*   if year>=2012 & year<=2017 & FR_nonFR_status =="never enrolled as FR" & satmat!=. & satverb!=. & MAJR_CODE!="MJRL"  & bla>10 & bla<=30 & non_div==1 ,   absorb(i.year##i.Dept2 fake_advisor_id) vce(  cluster advisorIDyear) 
eststo zab2
** PEERS EFFECTS for STUDEnTS FROM CHRISTIAN Schools*** (Christian match)
lincomest -stcath-christianchrist3  //All Christian schools peers relative to all Secular schools peers
eststo row34		
estimates restore zab2
lincomest -stcath-christianchrist3+stmusl+christianislam3 //All Christian schools peers relative to all Islamic schools peers
eststo row44	
estimates restore zab2

reghdfe musl_teach $treat satmat satverb sex* legacy advsex*   if year>=2012 & year<=2017 & FR_nonFR_status =="never enrolled as FR" & satmat!=. & satverb!=. & MAJR_CODE!="MJRL"  & bla>10 & bla<=30 & non_div==1 ,   absorb(i.year##i.Dept2 fake_advisor_id) vce(  cluster advisorIDyear)
eststo zab
** PEERS EFFECTS for STUDEnTS FROM ISLAMIC Schools*** (Islam match)
lincomest  -stmusl-islamicislam3 //All Islamic schools peers relative to all Secular schools peers7
eststo row54
estimates restore zab
lincomest  -stmusl-islamicislam3+stcath+islamicchrist3 //All Muslim school peers relative to all Christian schools peers
eststo row64
estimates restore zab


esttab row1* using Table6.tex, label  nocon  b(%9.3f) se(%9.3f) starlevels(* 0.1 ** 0.05 *** 0.01) replace
foreach i in  2 3 4 5 6{
esttab row`i'* using Table6.tex, label  nocon  b(%9.3f) se(%9.3f) starlevels(* 0.1 ** 0.05 *** 0.01) append
}






